package builders;

import entities.LineObject;
import entities.TemporarySpring;
import java.util.LinkedList;
import main.Simulation;

/**
 * Builds a temporary Spring.
 * @author Paul
 * @author Lance
 */
public class TemporarySpringBuilder extends LineObjectBuilder {
    
    /**
     * Builds a temporary spring.
     * @param pointObjectBuilder
     */
    public TemporarySpringBuilder(PointObjectBuilder pointObjectBuilder) {
        super(pointObjectBuilder);
    }

    /**
     * builds the spring.
     */
    public void build(Simulation sim, LinkedList<Double> properties) {
        int m1 = (int)(double)properties.poll();
        int m2 = (int)(double)properties.poll();
        double restLength = properties.poll();
        double ks = properties.poll();
        LineObject tempSpring = new TemporarySpring(getPointObjectBuilder().getPointObject(m1),
                getPointObjectBuilder().getPointObject(m2), restLength, ks);
        addToSimulation(sim, tempSpring);
        sim.setTemporarySpring(tempSpring);
    }

}
